package cn.shop.cloud.mapper;


import cn.shop.cloud.domain.SeckillGood;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @program: work
 * @ClassName SeckillGoodMapper
 * @description:
 * @author: 李尧坤
 * @create: 2025−01-08 20:20
 * @Version 1.0
 **/
@Mapper
public interface SeckillGoodMapper {

    @Select("SELECT * FROM t_seckill_goods")
    public List<SeckillGood> query();

    @Select("SELECT * FROM t_seckill_goods WHERE id =#{seckillId} ")
    public SeckillGood get(Long seckillId);

    @Update("update t_seckill_goods set stock_count=stock_count-1 where id=#{seckillId}")
    public void decrStock(Long seckillId);

    @Select("SELECT stock_count FROM t_seckill_goods WHERE id=#{seckillId}")
    public int getStockCount(Long seckillId);

    @Update("update t_seckill_goods set stock_count=stock_count+1 where id=#{seckillId} and stock_count>0")
    public void incrStock(Long seckillId);
}
